const express = require('express')
// 引入cors中间件
const cors = require('cors')

const app = express()

app.use(express.static('./public'))
app.use(express.urlencoded({ extended: false }))
// 这个中间件就负责在预请求的时候,往响应主体中添加属性Access-Control-Allow-Origin
app.use(cors())

app.post('/b', (req, res) => {
  console.log(req.body)
  res.send('post-响应了')
})
app.get('/b', (req, res) => {
  console.log(req.query)
  res.send('get-响应了')
})

app.listen(5000)
